package celular;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class FormLogin extends Form implements CommandListener
{
		
	private TextField textLogin, textSenha;
	private Command commandSair, commandLogar;
	private boolean cadastrado = false;
	private Main main;

	
	public FormLogin(String titulo, Main main)
	{
		
		super(titulo);
		
		this.main = main;
		this.commandSair = new Command("Sair", Command.EXIT, 0);	
		this.commandLogar = new Command("Logar", Command.OK, 1);	

		addCommand(this.commandSair);	
		addCommand(this.commandLogar);

		append(this.textLogin = new TextField("Login:", "", 20, TextField.ANY));
		append(this.textSenha = new TextField("Senha:", "", 20, TextField.ANY | TextField.PASSWORD));
		setCommandListener(this);   
		
		
	}
	
	public void commandAction(Command c, Displayable d)
	{
		if (c == this.commandSair)
			this.main.getTela().setCurrent(this.main.getMainForm());
		
		if (c == this.commandLogar) {
			
			//REPRESENTACAO DE LOGIN INEXISTENTE
			
			if (!this.textLogin.getString().equals("diego"))
				this.main.getTela().setCurrent(new FormLoginInvalido("Login e\\ou Senha Invalido",this.main));
			else
				this.main.getTela().setCurrent(new FormAdministracao("Administracao",this.main));
		}
	}
	
	
	
}


